/**
 * 
 */
package eu.digitalida.android.tutorial;

import android.graphics.Canvas;
import android.view.SurfaceHolder;

/**
 * @author Ahadu
 *
 */
public class TrackerThread extends Thread {

	private SurfaceHolder msurfaceHolder;
	private FlowerView flowerView;
	private boolean mrun = false;
	
	public TrackerThread(SurfaceHolder holder, FlowerView fv) {
		 msurfaceHolder = holder;
		 flowerView = fv;
	}

	public void startrun(boolean run) {
		mrun = run;
	}

	@Override
	public void run() {

	    super.run();
	     Canvas canvas;
	     while (mrun) {
	        canvas=null;
	         try {
	             canvas = msurfaceHolder.lockCanvas(null);
	              synchronized (msurfaceHolder) {
	               flowerView.onDraw(canvas);
	             }
	         } finally {
	                 if (canvas != null) {
	                 msurfaceHolder.unlockCanvasAndPost(canvas);
	             }
	         }
	     }
	  }


}
